function showEditor(a,b,c,d){
	
	if(a==0){
		//document.getElementById("contentOperationType").value="ADD";
	}else{
		//document.getElementById("contentOperationType").value="UPDATE";
		$("#serviceModId").val(a);
		$("#descTitle").val(b);
		$("#serviceContent").val(c);
		CKEDITOR.instances.serviceContent.setData(document.getElementById("content"+c).innerHTML);
	}
    document.getElementById("Layer1").style.display = "";
	var top = (document.body.clientHeight-600)/2+"px";
	var left = (document.body.clientWidth-760)/2+"px";
	var div = document.getElementById("Layer1");
	div.style.top = top;
	div.style.left = left;
	showEdit();
}
function showEdit(id){
	 document.getElementById("bgLayer").width = document.body.scrollWidth; 
	 document.getElementsByName("bgLayer")[0].style.display="";
	 document.getElementsByName("bgLayer")[0].style.height=document.body.scrollHeight;
	// alert(document.getElementById("Layer1"));
	 document.getElementById("Layer1").style.display="";
	 timer=setInterval(move,"100");
}
function hideEdit(){
clearInterval(timer);
document.getElementsByName("bgLayer")[0].style.display="none";
document.getElementsByName("Layer1")[0].style.display="none";
CKEDITOR.instances.serviceContent.setData("");
$("#descTitle").val("");
$("#serviceModId").val("");
}
function move(){
document.getElementsByName("Layer1")[0].style.top=document.body.scrollTop+(document.body.clientHeight-600)/2;
document.getElementsByName("Layer1")[0].style.left=document.body.scrollLeft+document.body.clientWidth/2-380;
}
function displayDiv(){
   document.getElementById("Layer1").style.display = "none";
   hideEdit();
}	


function submitText(){
	
    if($("#serviceModId").val()==""){
    	var title =    document.getElementById("descTitle").value;
    	var desc = CKEDITOR.instances.serviceContent.getData();
    		if(title!=""&&desc!=""){
    			
    			$.post("saveServiceDesc",
    				       { descriptionName: title, descriptionValue: desc },
    				       function(msg){
    				    	   document.getElementById("descTitle").value="";
    					    	CKEDITOR.instances.serviceContent.setData("");
    					    	hideEdit();
    					    	if(msg=="保存描述信息成功"){
    					    	        var otr = document.getElementById("serviceDescTable").insertRow(-1);
    					    	        var checkTd=document.createElement("td");
    					    	        var otd1 = document.createElement("td");
    					    	        otd1.innerHTML = title;
    					    	        var otd2 = document.createElement("td");
    					    	        var otd3 = document.createElement("td");
    					    	        otd2.innerHTML = desc;
    					    	        otd3.innerHTML = "<input type='button' onclick=deleteContent('"+title+"',this) value=删除 class='button' />";
    					    	        otr.appendChild(otd1); 
    					    	        otr.appendChild(otd2); 
    					    	        otr.appendChild(otd3); 
    					    	}
    					    	jAlert(msg,'消息');
    				       } 
    				); 
    		
    	}else{
    		jAlert('请您输入完整的内容', '消息');
    		return;
    	}
    }else{
    	submitModContent();
    }
	
}
/*
function modifyService(serviceId,serviceName,ServiceSpName,serviceServiceType){
	
	$("#queryResult").css("display","none");
		$("#editor").css("display","");
		$("#editorDesc").css("display","");
		$("#editor2").css("display","");
		$.ajax({   
	            url:'selectServicePageByServiceId',    
	            data: 'serviceId='+serviceId,
	            timeout:10000,
	            success: function(msg)   
	            {
		        	if(msg!=""){
			        	eval('var obj='+msg);
			        	sp = obj;
					   	var content = obj.contents;
					   	var products = obj.service.products;
					   	var tb = document.getElementById("serviceDescTable").childNodes;
					   	var tr = tb[0].childNodes;
					   	var length = tr.length;
					   	if(length>1){
					   		for(var i=1;i<length;i++){
					   			document.getElementById("serviceDescTable").deleteRow(1);
					   		}
					   	}
					   	tb = document.getElementById("serviceProductTable").childNodes;
					   	tr = tb[0].childNodes;
					   	length = tr.length;
					   	if(length>1){
					   		for(var i=1;i<length;i++){
					   			document.getElementById("serviceProductTable").deleteRow(1);
					   		}
					   	}
		
					   	for(var i=0;i<content.length;i++){
					   		var otr = document.getElementById("serviceDescTable").insertRow(-1);
			    	        var otd1 = document.createElement("td");
			    	        
			    	        var otd2 = document.createElement("td");
			    	        var otd3 = document.createElement("td");
			    	        otd1.innerHTML = content[i].title;
			    	        otd2.innerHTML = content[i].content;
			    	        otd3.innerHTML = "<input type=button class=button onclick=deleteContent('"+content[i].title+"',this); value=删除 />";
			    	        otr.appendChild(otd1); 
			    	        otr.appendChild(otd2); 
			    	        otr.appendChild(otd3); 
						}
					   	
					   	for(var i=0;i<products.length;i++){
					   		var otr = document.getElementById("serviceProductTable").insertRow(-1);
			    	        var otd1 = document.createElement("td");
			    	        var otd2 = document.createElement("td");
			    	        var otd3 = document.createElement("td");
			    	        var otd4 = document.createElement("td");
			    	        var otd5 = document.createElement("td");
			    	        var otd6 = document.createElement("td");
			    	        
			    	        otd1.innerHTML = products[i].productId;
			    	        otd2.innerHTML = products[i].productName;
			    	        otd3.innerHTML = products[i].productSummary;
			    	        otd4.innerHTML = products[i].productCost.money+"元/月";
			    	        otd5.innerHTML = products[i].productType;
			    	        otd6.innerHTML = "<input type=button class=button onclick=deleteProduct("+products[i].productId+",this); value=删除 />";
			    	        otr.appendChild(otd1); 
			    	        otr.appendChild(otd2); 
			    	        otr.appendChild(otd3); 
			    	        otr.appendChild(otd4); 
			    	        otr.appendChild(otd5); 
			    	        otr.appendChild(otd6); 
						}
					   	$("#orderUrl").val(sp.serviceOrder.redirectUrl);
			        	$("#orderMode option[value='"+sp.serviceOrder.serviceOrderMode+"']").attr("selected",true);
			        	$("#grade option[value='"+sp.recommandGrade+"']").attr("selected",true);
			        	$("#small").attr("src","../.."+sp.pageSmallIconPath);
			        	$("#logo").attr("src","../.."+sp.pageLogoPath);
			        	
				    }
	            },   
	            error: function (msg)   
	            {   
	            	jAlert('error','消息');
	            }   
	      });  
					
						
		        	
		        	$("#serviceId").val(serviceId);
		        	$("#serviceName").val(serviceName);
		        	$("#spname").val(ServiceSpName);
		        	
		        	$("#serviceType option[value='"+serviceServiceType+"']").attr("selected",true);
					
		        	
		       
	}
*/
	function deleteById(serviceId,name,node){
		jConfirm('你确定删除'+name+'吗?', '确认对话框', function(r) {
			if(r){
				$.ajax({
				    url: document.getElementById("contextPath").value+'/admin/deleteById?serviceId='+serviceId,
				    type: 'POST',
				    timeout: 10000,
				    error: function(){
				        jAlert('请求服务错误','消息');
				    },
				    success: function(msg){
				        if(msg!="F"){
				        	jAlert('删除增值业务成功','消息');
							var tr = node.parentNode.parentNode;
							document.getElementById("serviceTab").deleteRow(tr.rowIndex);
					    }else{
							jAlert("删除增值业务失败");
						}
				    }
				});
			}
		});
		
	}
	
	function deleteContent(descriptionName,a){
		
		jConfirm('你确定删除吗?', '确认对话框', function(r) {
			if(r){
				$.ajax({
				    url: document.getElementById("contextPath").value+'/admin/delServiceDesc',
				    type: 'POST',
				    data:"descriptionName="+descriptionName+"&deleteServiceSescType=update",
				    timeout: 10000,
				    error: function(){
				        jAlert('请求服务错误','消息');
				    },
				    success: function(msg){
				        if(msg=="删除增值业务描述信息成功"){
				        	var tab = document.getElementById("serviceDescTable");
			        		var tr = a.parentNode.parentNode;
			        		tab.deleteRow(tr.rowIndex);
				        }
				    }
				});
			}
		}
		);
		
	}
	
	function deleteProduct(id,a){
		jConfirm('你确定删除本条产品类别记录吗?', '确认对话框', function(r) {
			if(r){
				$.ajax  
			    (   
			        {   
			            url:document.getElementById("contextPath").value+'/admin/deleteProduct',    
			            data: "productId="+id,
			            timeout:10000,
			            success: function(msg)   
			            {
			        	if(msg == "删除增值业务产品类别成功"){
			        		var tab = document.getElementById("serviceProductTable");
			        		var tr = a.parentNode.parentNode;
			        		tab.deleteRow(tr.rowIndex);
			        	}
			        	jAlert(msg,'消息');
			            },   
			            error: function (msg)   
			            {   
			            	jAlert('删除增值业务产品类别失败','消息');
			            }   
			        }   
			    ); 
			}
		});
	}
/***********************************************************************************/	
	function showProductEditor(){
		document.getElementById("Layer2").style.display = "";
		var top = (document.body.clientHeight-600)/2+"px";
		var left = (document.body.clientWidth-760)/2+"px";
		var div = document.getElementById("Layer2");
		div.style.top = top;
		div.style.left = left;
		showProductEdit();
	}
	function showProductEdit(){
		 document.getElementById("bgLayer").width = document.body.scrollWidth; 
		 document.getElementsByName("bgLayer")[0].style.display="";
		 document.getElementsByName("bgLayer")[0].style.height=document.body.scrollHeight;
		 document.getElementById("Layer2").style.display="";
		 timer=setInterval(moveProduct,"100");
	}
	function hideProductEdit(){
		clearInterval(timer);
		document.getElementsByName("bgLayer")[0].style.display="none";
		document.all["Layer2"].style.display="none";
	}
	function moveProduct(){
		document.all["Layer2"].style.top=document.body.scrollTop+(document.body.clientHeight-600)/2;
		document.all["Layer2"].style.left=document.body.scrollLeft+document.body.clientWidth/2-380;
	}
	function displayDiv(){
	   document.getElementById("Layer2").style.display = "none";
	   hideProductEdit();
	}	
	
	function subPro(){
		var productFee = $("#productFee").val();
		var productDesc = $("#productDesc").val();
		var productName = $("#productName").val();
		var productId = $("#productId").val();
		
		var s = document.getElementById("serviceCodeType");
		var index  = s.selectedIndex;
		var serviceCodeType = $("#serviceCodeType").val();
		var serviceCodeTypeText = "" ;  
		if(serviceCodeType=="P"){
			serviceCodeTypeText = "产品类型";
		}else{
			serviceCodeTypeText = "套餐类型";
		}
		   
		if(productId==""){
			jAlert("请输入类别的代码",'消息');
			return;
		}else{
			if(isNaN(productId)){
				jAlert("请输入数字类型的类别代码",'消息');
				return;
			}
		}
		
		if(productName==""){
			jAlert("请输入类别的名称",'消息');
			return;
		}
		
		if(productDesc==""){
			jAlert("请输入类别的摘要信息",'消息');
			return;
		}
		
		if(productFee==""){
			jAlert("请输入类别的费用",'消息');
			return;
		}else{
			if(isNaN(productFee)){
				jAlert("请输入数字类型的费用",'消息');
				return;
			}
		}
		
		if(serviceCodeType==""){
			jAlert("请选择类别的产品类型",'消息');
			return;
		}
		
		$.ajax({
		    url: document.getElementById("contextPath").value+'/admin/saveProduct',
		    type: 'POST',
		    data: "productId="+productId+"&value="+productFee+"&productName="+productName+"&productSummary="+productDesc+"&productType="+serviceCodeType+"&canAccept="+$("#canAccept").val(),
		    timeout: 5000,
		    error: function(){
		    	jAlert('保存数据失败','消息');
		    },
		    success: function(msg){
		    	if(msg=="增加产品类别成功"){
	    	        var otr = document.getElementById("serviceProductTable").insertRow(-1);
	    	        var checkTd=document.createElement("td");
	    	        var otd1 = document.createElement("td");
	    	        otd1.innerHTML = productId;
	    	        var otd2 = document.createElement("td");
	    	        var otd3 = document.createElement("td");
	    	        otd2.innerHTML = productName;
	    	        otd3.innerHTML = productDesc;
	    	        
	    	        var otd4 = document.createElement("td");
	    	        var otd5 = document.createElement("td");
	    	        var otd6 = document.createElement("td");
	    	        otd4.innerHTML = productFee+"元/月";
	    	        otd5.innerHTML = serviceCodeTypeText;
	    	        otd6.innerHTML = "<input type=button class=button onclick=deleteProduct("+productId+",this); value=删除 />";
	    	        otr.appendChild(otd1); 
	    	        otr.appendChild(otd2); 
	    	        otr.appendChild(otd3);
	    	        otr.appendChild(otd4);
	    	        otr.appendChild(otd5);
	    	        otr.appendChild(otd6); 
	    	}	
		    	hideProductEdit();
		        jAlert(msg,'消息');
		        $("#productFee").val("");
		        $("#productDesc").val("");
		        $("#productName").val("");
		        $("#productId").val("");
		    }
		});
	}
	
	/************************************************************/
function showSmallUpload(){
    document.getElementById("Layer3").style.display = "";
	var top = (document.body.clientHeight-600)/2+"px";
	var left = (document.body.clientWidth-760)/2+"px";
	var div = document.getElementById("Layer3");
	div.style.top = top;
	div.style.left = left;
	showSmallEdit();
}
function showSmallEdit(id){
	 document.getElementById("bgLayer").width = document.body.scrollWidth; 
	 document.getElementsByName("bgLayer")[0].style.display="";
	 document.getElementsByName("bgLayer")[0].style.height=document.body.scrollHeight;
	// alert(document.getElementById("Layer1"));
	 document.getElementById("Layer3").style.display="";
	 timer=setInterval(moveSmallEdit,"100");
}
function hideSmallEdit(){
clearInterval(timer);
document.getElementsByName("bgLayer")[0].style.display="none";
document.all["Layer3"].style.display="none";
}
function moveSmallEdit(){
document.all["Layer3"].style.top=document.body.scrollTop+(document.body.clientHeight-600)/2;
document.all["Layer3"].style.left=document.body.scrollLeft+document.body.clientWidth/2-380;
}
function displaySmallDiv(){
   document.getElementById("Layer3").style.display = "none";
   hideSmallEdit();
}	
/************************************************************/

function showLogoUpload(){
    document.getElementById("Layer4").style.display = "";
	var top = (document.body.clientHeight-600)/2+"px";
	var left = (document.body.clientWidth-760)/2+"px";
	var div = document.getElementById("Layer4");
	div.style.top = top;
	div.style.left = left;
	showLogoEdit();
}
function showLogoEdit(id){
	 document.getElementById("bgLayer").width = document.body.scrollWidth; 
	 document.getElementsByName("bgLayer")[0].style.display="";
	 document.getElementsByName("bgLayer")[0].style.height=document.body.scrollHeight;
	// alert(document.getElementById("Layer1"));
	 document.getElementById("Layer4").style.display="";
	 timer=setInterval(moveLogoEdit,"100");
}
function hideLogoEdit(){
clearInterval(timer);
document.getElementsByName("bgLayer")[0].style.display="none";
document.all["Layer4"].style.display="none";
}
function moveLogoEdit(){
document.all["Layer4"].style.top=document.body.scrollTop+(document.body.clientHeight-600)/2;
document.all["Layer4"].style.left=document.body.scrollLeft+document.body.clientWidth/2-380;
}
function displayLogoDiv(){
   document.getElementById("Layer4").style.display = "none";
   hideSmallEdit();
}	


function showFlashUpload(){
    document.getElementById("Layer5").style.display = "";
	var top = (document.body.clientHeight-600)/2+"px";
	var left = (document.body.clientWidth-760)/2+"px";
	var div = document.getElementById("Layer5");
	div.style.top = top;
	div.style.left = left;
	showFlashEdit();
}
function showFlashEdit(id){
	 document.getElementById("bgLayer").width = document.body.scrollWidth; 
	 document.getElementsByName("bgLayer")[0].style.display="";
	 document.getElementsByName("bgLayer")[0].style.height=document.body.scrollHeight;
	// alert(document.getElementById("Layer1"));
	 document.getElementById("Layer5").style.display="";
	 timer=setInterval(moveFlashEdit,"100");
}
function hideFlashEdit(){
clearInterval(timer);
document.getElementsByName("bgLayer")[0].style.display="none";
document.all["Layer5"].style.display="none";
}
function moveFlashEdit(){
document.all["Layer5"].style.top=document.body.scrollTop+(document.body.clientHeight-600)/2;
document.all["Layer5"].style.left=document.body.scrollLeft+document.body.clientWidth/2-380;
}
function displayFlashDiv(){
   document.getElementById("Layer5").style.display = "none";
   hideFlashEdit();
}	
/************************************************************/



function uploadSmallIcon(){
	
	var url = document.getElementById("contextPath").value+'/admin/updateFile?updateType=small';
	if($("#smallImage1").val()==""){
		jAlert("请选择图片",'消息');
		return ;
	}
	$.ajaxFileUpload   
    (   
        {   
            url:url,    
            secureuri:false,   
            fileElementId:'smallImage1',   
            dataType: '',   
            success: function(data, status)   
            {      
               jAlert(status,'消息');
               var path = $('#small')[0].src;
               $("#small").attr("src","");
               $("#small").attr("src",path);
               displaySmallDiv();
            },   
            error: function (data, status, e)   
            {   
            	jAlert("保存文件失败",'消息');
            	displaySmallDiv();
            }   
        }   
    )  
}
function uploadLogoImage(){
	if($("#logoImage1").val()==""){
		jAlert("请选择图片",'消息');
		return ;
	}
	$.ajaxFileUpload   
    (   
        {   
            url:document.getElementById("contextPath").value+'/admin/updateFile?updateType=logo',    
            secureuri:false,   
            fileElementId:'logoImage1',   
            dataType: '',   
            success: function(data, status)   
            {      
               jAlert(status,'消息');
               displayLogoDiv();
            },   
            error: function (data, status, e)   
            {   
            	jAlert("保存文件失败",'消息');
            	displayLogoDiv();
            }   
        }   
    )  
}
function uploadFlash(){
	
	
	if($("#flash1").val()==""){
		jAlert("请选择图片",'消息');
		return ;
	}
	$.ajaxFileUpload   
    (   
        {   
            url:document.getElementById("contextPath").value+'/admin/updateFile?updateType=flash',    
            secureuri:false,   
            fileElementId:'flash1',   
            dataType: '',   
            success: function(data, status)   
            {      
               jAlert(status,'消息');
               displayFlashDiv();
            },   
            error: function (data, status, e)   
            {   
            	jAlert("保存文件失败",'消息');
            	displayFlashDiv();
            }   
        }   
    )  
}


function saveService(){
	if($("#serviceName").val()==""){
		jAlert("请输入增值业务名称","消息");
		$("#serviceName").focus();
		return ;
	}
	
	if($("#spname").val()==""){
		jAlert("请输入增值业务提供商","消息");
		$("#spname").focus();
		return ;
	}
	
	if($("#serviceSummaryContent").val()==""){
		jAlert('请输入增值业务的简要描述', '消息');
		$("#serviceSummaryContent").focus();
		return false;
	}
	
	var tb = document.getElementById("serviceDescTable").childNodes;
   	var tr = tb[0].childNodes;
   	var length = tr.length;
   	//alert("增值业务描述信息"+length+"条");
   	if(length<2){
   		jAlert("增值业务描述信息至少要保留一条","消息");
   		return;
   	}
   
   	tb = document.getElementById("serviceProductTable").childNodes;
   	tr = tb[0].childNodes;
   	length = tr.length;
   	if(length<2){
   		jAlert("增值业务产品类别至少要保留一条","消息");
   		return;
   	}
   	if($("#orderMode").val()!="CRM"&&$("#orderMode").val()!="ISMP"){
   		if($("#orderUrl").val()==""){
   			jAlert("请输入跳转或单点登陆的URL","消息");
   	   		return;
   		}
   		
   	}
   	document.getElementById("serviceform").submit();
   	
   	
   	
 /*  	$.ajax({
	    url: 'updateService',
	    type: 'POST',
	    data:"orderMode="+$("#orderMode").val()+"&redirectUrl="+$("#orderUrl").val()+"&serviceName="+$("#serviceName").val()+"&spName="+$("#spname").val()+"&serviceCodeGrade="+$("#grade").val()+"&serviceClassify="+$("#serviceClassify").val()+"&serviceType="+$("#serviceType").val(),
	    timeout: 10000,
	    error: function(){
	        jAlert('请求服务错误','消息');
	    },
	    success: function(msg){
	        if(msg!="保存成功"){
	        	window.location.href="../success.jsp";
	        }else{
	        	alert(msg);
	        }
	    }
	});*/
}

function modifyContent(id,title,i,node){
	
	showContentEditor();
	$("#serviceModId").val(id);
	$("#serviceModeTitle").val(title);
	$("#serviceModeTitleTemp").val(title);
	
	CKEDITOR.instances.serviceModContent.setData(document.getElementById("content"+i).innerHTML);
	
}

function showContentEditor(){
    document.getElementById("Layer6").style.display = "";
	var top = (document.body.clientHeight-600)/2+"px";
	var left = (document.body.clientWidth-760)/2+"px";
	var div = document.getElementById("Layer6");
	div.style.top = top;
	div.style.left = left;
	showEdit();
}
function showContentEdit(id){
	 document.getElementById("bgLayer").width = document.body.scrollWidth; 
	 document.getElementsByName("bgLayer")[0].style.display="";
	 document.getElementsByName("bgLayer")[0].style.height=document.body.scrollHeight;
	// alert(document.getElementById("Layer1"));
	 document.getElementById("Layer6").style.display="";
	 timer=setInterval(moveContent,"100");
}
function hideContentEdit(){
clearInterval(timer);
document.getElementsByName("bgLayer")[0].style.display="none";
document.all["Layer6"].style.display="none";
}
function moveContent(){
document.all["Layer6"].style.top=document.body.scrollTop+(document.body.clientHeight-600)/2;
document.all["Layer6"].style.left=document.body.scrollLeft+document.body.clientWidth/2-380;
}
function displayContentDiv(){
   document.getElementById("Layer6").style.display = "none";
   hideEdit();
}	

function submitModContent(){
	var id = $("#serviceModId").val();
	var title = $("#descTitle").val();
	var titleTemp = $("#serviceContent").val();
	var content = CKEDITOR.instances.serviceContent.getData();
	
	
	//alert(content);
	
	if(title==""||title==null){
		jAlert("请输入描述信息名称","消息");
		return;
	}
	
	if(content==""||content==null){
		jAlert("请输入描述信息内容","消息");
		return;
	}
	var path = document.getElementById("contextPath").value;
	path +="/admin/updateServicePageContent";
	
	//alert(path);
	
	$.post("updateServicePageContent",
		       { descriptionName: title, descriptionValue: content ,descriptionId:id,titleTemp:titleTemp},
		       function(msg){
		    	   jAlert(msg,'消息');
			        var tab = document.getElementById("serviceDescTable");
			       if(msg=="更新成功"){ 
			        	tab.deleteRow(document.getElementById("con"+id).parentNode.parentNode.rowIndex);
			        	
			        	var otr = document.getElementById("serviceDescTable").insertRow(-1);
		    	        var checkTd=document.createElement("td");
		    	        var otd1 = document.createElement("td");
		    	        otd1.innerHTML = title;
		    	        var otd2 = document.createElement("td");
		    	        var otd3 = document.createElement("td");
		    	        var otd4 = document.createElement("td");
		    	        otd2.innerHTML = content;
		    	        otd3.innerHTML = "<input type='button' onclick=deleteContent('"+title+"',this) value=删除 class='button' />";
		    	        otd4.innerHTML = "<input type='button' id='con"+id+"' onclick=modifyContent('"+id+"','"+title+"',this) value=编辑 class='button' />";
		    	        otr.appendChild(otd1); 
		    	        otr.appendChild(otd2); 
		    	        otr.appendChild(otd3); 
		    	        otr.appendChild(otd4); 
			        	
			        }
			       hideEdit();
		       } 
		); 
	
	
	
}

/**********************************************************************************/
function showProductEditor2(){
	document.getElementById("Layer7").style.display = "";
	var top = (document.body.clientHeight-600)/2+"px";
	var left = (document.body.clientWidth-760)/2+"px";
	var div = document.getElementById("Layer7");
	div.style.top = top;
	div.style.left = left;
	showProductEdit();
}
function showProductEdit2(){
	 document.getElementById("bgLayer").width = document.body.scrollWidth; 
	 document.getElementsByName("bgLayer")[0].style.display="";
	 document.getElementsByName("bgLayer")[0].style.height=document.body.scrollHeight;
	 document.getElementById("Layer7").style.display="";
	 timer=setInterval(moveProduct2,"100");
}
function hideProductEdit2(){
	clearInterval(timer);
	document.getElementsByName("bgLayer")[0].style.display="none";
	document.all["Layer7"].style.display="none";
}
function moveProduct2(){
	document.all["Layer7"].style.top=document.body.scrollTop+(document.body.clientHeight-600)/2;
	document.all["Layer7"].style.left=document.body.scrollLeft+document.body.clientWidth/2-380;
}
function displayDiv7(){
   document.getElementById("Layer7").style.display = "none";
   hideProductEdit();
}	

function updateProduct(id,name,sumary,cost,producttype,canaceept,node){
	showProductEditor2();
	$("#modProductId").val(id);
	$("#modProductName").val(name);
	$("#modProductDesc").val(sumary);
	$("#modProductFee").val(cost);
	$("#modServiceCodeType option[value='"+producttype+"']").attr("selected",true);
	$("#modCanAccept option[value='"+modCanAccept+"']").attr("selected",true);
	
}

function subUpdateProduct(){
	
	var id = $("#modProductId").val();
	var name = $("#modProductName").val();
	var desc = $("#modProductDesc").val();
	var fee = $("#modProductFee").val();
	var type = $("#modServiceCodeType").val();
	var canaccept = $("#modCanAccept").val();
	
	var input = document.getElementById("pro"+id);
	$.ajax({
	    url: document.getElementById("contextPath").value+'/admin/updateProduct',
	    type: 'POST',
	    data: "productId="+id+"&value="+fee+"&productName="+name+"&productSummary="+desc+"&productType="+type+"&canAccept="+canaccept,
	    timeout: 10000,
	    error: function(){
	    	jAlert('请求服务异常','消息');
	    },
	    success: function(msg){
	    	
	    	alert(msg);
	    	var tab = document.getElementById("serviceProductTable");
	    	
	    	if(msg=="更新成功"){
	    		tab.deleteRow(input.parentNode.parentNode.rowIndex);
    	        var otr = document.getElementById("serviceProductTable").insertRow(-1);
    	        var checkTd=document.createElement("td");
    	        var otd1 = document.createElement("td");
    	        otd1.innerHTML = id;
    	        var otd2 = document.createElement("td");
    	        var otd3 = document.createElement("td");
    	        otd2.innerHTML = name;
    	        otd3.innerHTML = desc;
    	        
    	        var otd4 = document.createElement("td");
    	        var otd5 = document.createElement("td");
    	        var otd6 = document.createElement("td");
    	        var otd7 = document.createElement("td");
    	        otd4.innerHTML = fee+"元/月";
    	        if("P"==type){
    	        	otd5.innerHTML = "产品类型";
    	        }else{
    	        	otd5.innerHTML = "套餐类型";
    	        }
    	        
    	        otd6.innerHTML = "<input type=button class=button onclick=deleteProduct("+id+",this); value=删除 />";
    	        otd7.innerHTML = "<input type=button class=button id=pro"+id+" onclick=\"updateProduct('"+id+"','"+name+"','"+desc+"','"+fee+"','"+type+"','"+canaccept+"',this);\" value=编辑 />";
    	        otr.appendChild(otd1); 
    	        otr.appendChild(otd2); 
    	        otr.appendChild(otd3);
    	        otr.appendChild(otd4);
    	        otr.appendChild(otd5);
    	        otr.appendChild(otd6); 
    	        otr.appendChild(otd7); 
    	}	
	    	displayDiv7();
	    } 
	});
	
	
}